package cn.edu.scau.cmi.wangzm.composite.consistent;

import java.util.Iterator;
import java.util.Set;

public class ConsistentOutput {
      public void Output(ConsistentComponent trunk) {
    	  Set<ConsistentComponent> trunkChildren = trunk.getChildren();
  		Iterator<ConsistentComponent> trunkChildrenIterator = trunkChildren.iterator();
  		System.out.println(((ConsistentComposite)trunk).getName());
  		while(trunkChildrenIterator.hasNext()) {
  			ConsistentComposite text=new ConsistentComposite();
  			text=(ConsistentComposite)trunkChildrenIterator.next();
  			System.out.println("    "+text.getName());
  			if(text.getChildren()!=null) {
  				Set<ConsistentComponent> BranchChildren = text.getChildren();
  				Iterator<ConsistentComponent> BranchChildrenIterator = BranchChildren.iterator();
  				while(BranchChildrenIterator.hasNext()) {
  					System.out.println("      "+((ConsistentLeaf)BranchChildrenIterator.next()).getName());
  				}
  			}
  			}
      }
}
